#ifndef _SEMAPHORE_H_
#define _SEMAPHORE_H_

#include "process.h"

// added @lab3-challenge2

#define NSEM NPROC
// #define SEM_OK 0
// #define SEM_ERR 1

typedef enum sem_status_t {
  SEM_OK,
  SEM_ERR
} sem_status;

// 信号量结构定义
typedef struct semaphore_t {
  int value;        // 信号灯的值 
  process* wq_head; // waiting queue head
  process* wq_tail; // waiting queue tail
} semaphore;

int do_sem_new(int value);
sem_status do_sem_P(int sem_id);
sem_status do_sem_V(int sem_id);
sem_status do_sem_free(int sem_id);


#endif // _SEMAPHORE_H_
